<LayoutEditFormBox :loading="load">

    <template slot="main">
        <el-form ref="editForm" :model="form" label-width="140px" label-position="left">
            <LayoutCell>
                <LayoutCellItem title="分销设置">
                    <el-form-item label="分销层级" prop="level" :rules="{ required: true, message: '请选择分销层级'}">
                        <el-radio-group v-model="form.level">
                            <el-radio :label="0">关闭</el-radio>
                            <el-radio :label="1">一级分销</el-radio>
                            <el-radio :label="2">二级分销</el-radio>
                            <!-- <el-radio :label="3">三级分销</el-radio> -->
                        </el-radio-group>
                    </el-form-item>
                    
                    <el-form-item label="分销自购" prop="self_buy" :rules="{ required: true, message: '请选择'}">
                        <el-radio-group v-model="form.self_buy">
                            <el-radio :label="false">关闭</el-radio>
                            <el-radio :label="true">自购返佣</el-radio>
                            <!-- <el-radio :label="2">自购优惠</el-radio> -->
                        </el-radio-group>
                        <div class="text">自购优惠开启后，分销商自己购买商品时，可以直接优惠下单，不再返佣。</div>
                    </el-form-item>

                    <!-- <el-form-item label="是否需要审核">
                        <el-radio-group v-model="form.need_check">
                            <el-radio :label="true">需要</el-radio>
                            <el-radio :label="false">不需要</el-radio>
                        </el-radio-group>
                    </el-form-item> -->
                </LayoutCellItem>

                <LayoutCellItem title="分销商资格">
                    <el-form-item label="成为分销商条件" prop="become" :rules="{ required: true, message: '请选择成为分销商的条件'}">
                        <el-radio-group v-model="form.become">
                            <el-radio :label="0">无条件</el-radio>
                            <el-radio :label="1">申请</el-radio>
                            <el-radio :label="2">消费次数</el-radio>
                            <el-radio :label="3">消费金额</el-radio>
                            <el-radio :label="4">购买商品</el-radio>
                        </el-radio-group>
                    </el-form-item>

                    <el-form-item label="指定商品" v-if="form.become == 4">
                        <el-table :data="levelList" v-loading="mixinTable_loading"  border style="width: 100%;height: 100%;" :ref="mixinPage_vueName+'TableSmall'"
                                @selection-change="mixinTable_handleSelectionChangeTableSmall">
                            <el-table-column prop="name" label="等级名称" width="100"></el-table-column>
                            <el-table-column prop="name" label="商品">
                                <template slot-scope="scope">
                                    <SelectDataGoods v-model="scope.row.goods_ids" :appWindow="appWindow" :count="100" :disabled="mixinEdit_editType == 'update'" 
                                        :apiConfig="$vFN.Tools.getAppGlobalData('componentsApiConfig.SelectDataGoods',appWindow)">
                                    </SelectDataGoods>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-form-item>

                    <el-form-item label="商品样式" v-if="form.become == 4" prop="become_good_style" :rules="{ required: true, message: '商品样式 不能为空'}">
                        <el-radio-group v-model="form.become_good_style">
                            <el-radio :label="1">单列商品</el-radio>
                            <el-radio :label="2">双列商品</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="累计消费次数" v-if="form.become == 2" prop="become_order_count" :rules="{ required: true, message: '累计消费次数 不能为空'}">
                        <el-input v-model="form.become_order_count" style="width: 200px;"><template slot="append">次</template></el-input>
                    </el-form-item>
                    <el-form-item label="累计消费金额" v-if="form.become == 3" prop="become_money_count" :rules="{ required: true, message: '累计消费金额 不能为空'}">
                        <el-input v-model="form.become_money_count" style="width: 200px;"><template slot="append">元</template></el-input>
                    </el-form-item>
                    <el-form-item label="消费条件" v-if="form.become == 2 || form.become == 3 || form.become == 4" prop="become_order_status" :rules="{ required: true, message: '商品样式 不能为空'}">
                        <el-radio-group v-model="form.become_order_status">
                            <el-radio :label="1">付款后</el-radio>
                            <el-radio :label="2">订单完成</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    
                    <el-form-item label="申请页面顶部图片" v-if="form.become != 0" prop="background_img" :rules="{ required: true, message: '图片 不能为空'}">
                        <SelectImageRadio v-model="form.background_img" :appWindow="appWindow"
                                :apiConfig="$vFN.Tools.getAppGlobalData('selectResourcesImageApiConfig.resourcesImageBox', appWindow)">
                            </SelectImageRadio>
                    </el-form-item>

                    <div v-if="form.become == 1">
                        <el-form-item label="显示申请协议" prop="open_protocol" :rules="{ required: true, message: '请选择'}">
                            <el-radio-group v-model="form.open_protocol">
                                <el-radio :label="true">显示</el-radio>
                                <el-radio :label="false">隐藏</el-radio>
                            </el-radio-group>
                        </el-form-item>

                        <el-form-item label="分销商特权" prop="commission_privilege_switch" :rules="{ required: true, message: '请选择'}">
                            <el-radio-group v-model="form.commission_privilege_switch">
                                <el-radio :label="true">系统默认</el-radio>
                                <el-radio :label="false">自定义内容</el-radio>
                            </el-radio-group>
                        </el-form-item>
                        <el-form-item label="" v-if="form.commission_privilege_switch == false" prop="commission_privilege" :rules="{ required: true, message: '不能为空'}">
                            <el-input v-model="form.commission_privilege" type="textarea" :row="5" maxlength="500" show-word-limit></el-input>
                        </el-form-item>

                        <el-form-item label="完善资料" prop="become_register" :rules="{ required: true, message: '请选择'}">
                            <el-radio-group v-model="form.become_register">
                                <el-radio :label="true">需要</el-radio>
                                <el-radio :label="false">不需要</el-radio>
                            </el-radio-group>
                            <div class="text">申请成为分销商是否必须完善资料</div>
                        </el-form-item>

                        <el-form-item label="资料内容" v-if="form.become_register == true" prop="become_register_form" :rules="{ required: true, message: '不能为空'}">
                            <div style="margin-bottom: 10px;">
                                <span style="display: inline-block;width: 300px;">资料名称</span><span style="display: inline-block;margin-left: 15px;">操作</span>
                            </div>
                            <div v-for="(item, index) in form.become_register_form" class="input-inline">
                                <el-input style="width: 300px;" v-model="form.become_register_form[index]" maxlength="10" show-word-limit></el-input><span class="del-text" @click="del(item, index)">删除</span>
                            </div>
                            <div class="add-text" @click="add()" v-show="form.become_register_form.length != 5">+添加资料项{{form.become_register_form.length}}/5</div>
                        </el-form-item>
                    </div>
                </LayoutCellItem>

                <!-- <LayoutCellItem title="上下线关系">
                    <el-form-item label="成为下线条件" prop="become_child" :rules="{ required: true, message: '请选择'}">
                        <el-radio-group v-model="form.become_child">
                            <el-radio :label="1">首次点击分享链接</el-radio>
                            <el-radio :label="2">首次下单</el-radio>
                            <el-radio :label="3">首次付款</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </LayoutCellItem> -->

                <LayoutCellItem title="分销商品">
                    <el-form-item label="商品默认参与分销" prop="goods_join_commission" :rules="{ required: true, message: '请选择'}">
                        <el-radio-group v-model="form.goods_join_commission">
                            <el-radio :label="true">是</el-radio>
                            <el-radio :label="false">否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </LayoutCellItem>
            </LayoutCell>
        </el-form>
    </template>
    <template slot="footer">
        <el-button type="primary" @click="sum()">确定</el-button>
    </template>

</LayoutEditFormBox>